using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

using EMan.Interface.EnterpriseStructure.Employees;

using TrueCode.Core.Aspects;

namespace EMan.Interface.EnterpriseStructure.Departments
{
  public partial class DepartmentEditable : IStructureTreeNode
  {
    private readonly ObservableCollection< EmployeeEditable > _employees      = new ObservableCollection< EmployeeEditable >();

    public IEnumerable< EmployeeEditable > Employees{ get { return _employees;  } }

    public void Add( [ NotNull ] EmployeeEditable employeeEditable )
    {
      #region Validation
      if( employeeEditable == null ) throw new ArgumentNullException( "employeeEditable" );
      if( employeeEditable.Entity.Department != Entity ) throw new ArgumentException( "Employees' department is not this", "employeeEditable" );
      #endregion

      _entity.Add( employeeEditable.Entity );
      _employees.Add( employeeEditable );
    }

    public void Attach( EmployeeEditable employeeEditable )
    {
      #region Validation
      if( employeeEditable == null ) throw new ArgumentNullException( "employeeEditable" );
      if( employeeEditable.Entity.Department != Entity ) throw new ArgumentException( "Employees' department is not this", "employeeEditable" );
      #endregion
      _employees.Add( employeeEditable );
    }
  }
}